package com.example.pm.ending.server.controller;

import com.example.pm.ending.server.pojo.dto.HouseAddDTO;
import com.example.pm.ending.server.pojo.vo.HouseListVO;
import com.example.pm.ending.server.service.IHouseService;
import com.example.pm.ending.server.web.JsonResult;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Slf4j
@RestController
@RequestMapping("/House")
@Api(tags = "房产管理模块")
public class HouseController {

    @Autowired private IHouseService service;

    /**
     * @author JJS
     */
    /**
     * 新增房产信息
     * @param houseAddDTO
     * @return
     */
    @PostMapping("/addNew")
    public JsonResult addNew(HouseAddDTO houseAddDTO){
        service.addNew(houseAddDTO);
        log.info("插入数据{}",houseAddDTO);
        return JsonResult.ok();
    }

    /**
     * 房产列表
     * @return list
     */
    @GetMapping("/list")
    public JsonResult<List<HouseListVO>> list(){
        List<HouseListVO> list = service.list();
        log.info("列表数据{}",list);
        return JsonResult.ok(list);
    }
}
